<template>
	<view class="liu_content">
		<view>
			<u-tabs-swiper ref="uTabs" :list="list" name="title" :current="current" @change="tabsChange"
				:is-scroll="false" swiperWidth="750"></u-tabs-swiper>
		</view>
		<view class="content">
			<template v-if="articleList.length > 0 ">
				<view v-for="i in articleList" @click="handleClick(i.id)" class="u-body-item">
					<image style="margin-right:10rpx;"
						src="https://blog.dbsgw.com/content/templates/Fys/images/random/4.jpg" mode="aspectFill">
					</image>
					<view class="u-body-item-title">
						<view class="content_title">
							{{i.title}}
						</view>

						<info></info>


					</view>
				</view>
			</template>
			<!-- 数据为空时展示 -->
			<template v-else>
				<u-empty margin-top="50px" mode="data">
				</u-empty>
			</template>
		</view>
	</view>
</template>

<script>
	import {
		getTagList,
		getTagArticle
	} from './api/api.js'
	import info from '../../components/info.vue'
	export default {
		components: {
			info
		},
		data() {
			return {
				list: [],
				// 因为内部的滑动机制限制，请将tabs组件和swiper组件的current用不同变量赋值
				current: 0, // tabs组件的current值，表示当前活动的tab选项
				articleList: [],
			};
		},
		methods: {
			handleClick(id) {
				console.log(id)
				uni.navigateTo({
					url: '/pages/article/article?id=' + id,
				});
			},
			// tabs通知切换
			tabsChange(index) {
				console.log(this.list[index].id)
				this.current = index;

				this.getArticle(this.list[index].id)
			},
			// 文章请求
			getArticle(id) {
				getTagArticle(id).then(x => {
					console.log(x)
					this.articleList = x.data.data
				})
			}
		},
		created() {
			getTagList().then(x => {
				console.log(x)
				this.list = x.data.data
			})
			this.getArticle(2)
		}
	}
</script>


<style>
	/* 解决小程序和app滚动条的问题 */
	/* #ifdef MP-WEIXIN || APP-PLUS */
	::-webkit-scrollbar {
		display: none;
		width: 0 !important;
		height: 0 !important;
		-webkit-appearance: none;
		background: transparent;
		color: transparent;
	}

	/* #endif */
</style>
<style scoped lang="scss">
	.liu_content {
		height: 100%;
	}

	.content_title {
		font-size: 26rpx;
		font-weight: 600;
	}

	.content {
		height: calc(100% - 80rpx);
		background: #f6f6f6;
		overflow: hidden;
	}

	.u-body-item-title {
		height: 120rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.u-card-wrap {
		background-color: $u-bg-color;
		padding: 1px;
	}

	.u-body-item {
		font-size: 32rpx;
		color: #333;
		padding: 20rpx;
		background-color: #fff;
		border-radius: 10rpx;
		overflow: hidden;
		margin: 20rpx;
		display: flex;
		align-items: center;
	}

	.u-body-item image {
		width: 120rpx;
		flex: 0 0 120rpx;
		height: 120rpx;
		border-radius: 8rpx;
		margin-left: 12rpx;
	}

	uni-page-body {
		height: 100%;
	}

	p {
		overflow: hidden;
	}

	.scroll_view_content {
		width: 100%;
		// #ifdef H5
		padding-bottom: 40px;
		// #endif
	}
</style>
